
package asteroids.model.expressions;

import exceptions.IllegalOperandException;

/**
 * A subclass of expression (E) that represents the cosinus (cos x) of a double
 * 
 * @version 1.0
 * 
 * @author	Thijs Peirelinck & Wouter Parys
 *
 */
public class Cos extends MathExpression {

	public Cos(E e) {
		super(e);
	}

	@Override
	public Double getValue() {
		if(!this.isValidExpression()) { throw new IllegalOperandException(); }
		return Math.cos(((Double)getOperand().getValue()));
	}
	
	@Override
	public String toString() {
		return "cos(" + getOperand().toString() + ")";
	}

	@Override
	public Cos createCopy() {
		return new Cos(getOperand().createCopy());
	}
}
